//
//  ACPlayBackBarView.m
//  ACLiteAVUISDK
//
//  Created by 冯琰琰 on 2021/7/8.
//

#import "ACPlayBackBarView.h"

@interface ACPlayBackBarView ()

@property(nonatomic,strong)UILabel *currentTime;
@property(nonatomic,strong)UIImageView *bgView;
@property(nonatomic,strong)UIButton *statusBtn;
@property(nonatomic,strong)UISlider *progressView;
@property(nonatomic,strong)UILabel *totalTime;

@end

@implementation ACPlayBackBarView

-(instancetype)init{
    if (self = [super init]) {
        [self addSubViews];
    }
    return self;
}

-(void)addSubViews{
    self.bgView = [[UIImageView alloc] initWithImage:[UIImage imageWithName:@"icon_live_room_bg_bar" bundle:ACLiteAVUISDK targetClass:[self class]]];
    [self addSubview:self.bgView];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    
    self.statusBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.statusBtn setImage:[UIImage imageWithName:@"icon_stop_normal" bundle:ACLiteAVUISDK targetClass:[self class]] forState:UIControlStateNormal];
    [self.statusBtn setImage:[UIImage imageWithName:@"icon_start_normal" bundle:ACLiteAVUISDK targetClass:[self class]] forState:UIControlStateSelected];
    [self.bgView addSubview:self.statusBtn];
    [self.statusBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView.mas_left).offset(10);
        make.size.mas_equalTo(CGSizeMake(40, 40));
        make.centerY.equalTo(self.bgView.mas_centerY).mas_offset(5);
    }];
    
    self.currentTime = [[UILabel alloc] init];
    self.currentTime.text = @"00:00:00";
    self.currentTime.textAlignment = NSTextAlignmentLeft;
    self.currentTime.textColor = [UIColor whiteColor];
    self.currentTime.font = [UIFont systemFontOfSize:12.0];
    [self.bgView addSubview:self.currentTime];
    [self.currentTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.statusBtn.mas_right);
        make.centerY.equalTo(self.bgView.mas_centerY).mas_offset(5);
    }];
    
    self.totalTime = [[UILabel alloc] init];
    self.totalTime.text = @"00:00:00";
    self.totalTime.textAlignment = NSTextAlignmentRight;
    self.totalTime.textColor = [UIColor whiteColor];
    self.totalTime.font = [UIFont systemFontOfSize:12.0];
    [self.bgView addSubview:self.totalTime];
    [self.totalTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.bgView.mas_centerY).mas_offset(5);
        make.right.equalTo(self.bgView.mas_right).offset(-15);
    }];
    
    self.progressView = [[UISlider alloc] init];
    self.progressView.maximumValue = 1;
    self.progressView.minimumValue = 0;
    [self.progressView setThumbImage:[UIImage imageWithName:@"Oval" bundle:ACLiteAVUISDK targetClass:[self class]] forState:UIControlStateNormal];
    
    [self.bgView addSubview:self.progressView];
    [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(18);
        make.left.equalTo(self.currentTime.mas_right).offset(5);
        make.centerY.equalTo(self.bgView.mas_centerY).mas_offset(5);
        make.right.equalTo(self.totalTime.mas_left).offset(-10);
    }];
}

@end
